/*
 * decoder.c
 *
 *  Created on: 2015-03-22
 *      Author: root
 */
#include "decoder.h"


void tokenize(void);

char msgBuff[100];

char gUartIndex=0;
char gUartRead=0;
char gUartBuffer[100];
char decodeBuff[100];
char index1=0;
char index2=0;


void readBuff(void)
{
	index1=0;
	while (gUartIndex != gUartRead)
	{
		decodeBuff[index1]=gUartBuffer[gUartRead];
		if (decodeBuff[index1] == 13) { decode(index1); }
		gUartRead++;
		index1++;
		if ( index1 > 99) { index1=0; }	//overflow condition, should not be met
		if ( gUartRead > 99) { gUartRead=0; }
	}
}
void decode(int length)
{
	switch (decodeBuff[0])
	{
	case 'a':

		break;
	case 'b':
		bt_UARTsend("message received!\r\n");
		break;
	case 'p':
		if (decodeBuff[1] == 'w' && decodeBuff[2] == 'm')
		{
			int temp=0;
			if (length < 6)
			{
				bt_UARTsend("please enter speed\r\n");
			}
		}
	}
}


void tokenize(void)
{

}
